package com.xidian.zhiancloud.controller.riskcontrol.risksystem;

import com.github.pagehelper.Page;
import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.riskcontrol.TControlLevelStatusList;
import com.xidian.zhiancloud.qo.BaseReqQuery;
import com.xidian.zhiancloud.service.riskcontrol.risksystem.TControlLevelStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * 风险管控-系统设置-管控层级设置
 */
@RestController
@RequestMapping("/tconlevsta")
public class TControlLevelStatusController extends BaseController {

    @Autowired
    TControlLevelStatusService tControlLevelStatusService;

    /**
     * 系统设置-管控层级设置列表
     * @param reqdata 多对象集合
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/getTControlLevelStatusList")
    public ResultDTO getTControlLevelStatusList(BaseReqQuery reqdata){
        Long companyId=this.getSessionUserCompanyId();
        Page<TControlLevelStatusList> pagedata =
           tControlLevelStatusService.getTControlLevelStatusList
                   (reqdata,companyId);
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("datalist", pagedata);
        data.put("PageNum", pagedata.getPageNum());
        data.put("PageSize", pagedata.getPageSize());
        data.put("PageTotal", pagedata.getPages());
        data.put("total", pagedata.getTotal());
        return ResultDTO.successOf(data, GeneralResponseEnums.SUCCESS);

    }

    /**
     * 系统设置-管控层级设置修改
     *
     * @param id 管控层级设置表ID
     * @param levelSys 风险控制层级
     * @param need 职责要求
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/updateTControlLevelStatus")
    public ResultDTO updateTControlLevelStatus
        (@RequestParam("id") String id,@RequestParam("levelSys") String levelSys,
         @RequestParam("need") String need){
        Long companyId=this.getSessionUserCompanyId();
        tControlLevelStatusService.updateTControlLevelStatus
                (companyId,id,levelSys,need);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

}
